import axios from 'axios';
import store from '../vuex/store';
import {
    Message, MessageBox
  } from 'element-ui';

  // 创建axios实例
const service = axios.create({
    // baseURL: process.env.BASE_API, // api的base_url
    timeout: 5000 // 请求超时时间
  });

// request拦截器
service.interceptors.request.use(config => {
  // Do something before request is sent
  if (store.getters.id) {
    config.headers['Authorization'] = store.getters.id; // 让每个请求携带token--['X-Token']为自定义key 请根据实际情况自行修改
    // config.headers['Authorizations'] = store.getters.name;
  }
  return config;
}, error => {
  // Do something with request error
  console.log(error); // for debug
  Promise.reject(error);
})

export default service;